package br.com.livro.javapersistence.others.model;

import java.util.Date;

/**
 * @author leo
 * 
 */
public class InfoDetail {

	private Long userId;
	private Date creationDate;
	private String comments;

	/**
	 * 
	 */
	public InfoDetail() {
	}

	/**
	 * @param comments
	 */
	public InfoDetail(String comments) {
		this(null, comments);
	}

	/**
	 * @param creationDate
	 * @param comments
	 */
	public InfoDetail(Date creationDate, String comments) {
		this(null, creationDate, comments);
	}

	/**
	 * @param userId
	 * @param creationDate
	 * @param comments
	 */
	public InfoDetail(Long userId, Date creationDate, String comments) {
		this.setUserId(userId);
		this.setComments(comments);
		this.setCreationDate(creationDate);
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		if (creationDate == null)
			creationDate = new Date();
		this.creationDate = creationDate;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((comments == null) ? 0 : comments.hashCode());
		result = prime * result + ((creationDate == null) ? 0 : creationDate.hashCode());
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		InfoDetail other = (InfoDetail) obj;
		if (comments == null) {
			if (other.comments != null)
				return false;
		} else if (!comments.equals(other.comments))
			return false;
		if (creationDate == null) {
			if (other.creationDate != null)
				return false;
		} else if (!creationDate.equals(other.creationDate))
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}
}
